'''
Created on 2014. 3. 31.

@author: ...inger
'''
#데이터를 저장할 DB의 위치 설정
dbLocation = '../db/example.db'

import sqlite3

class DB(object):
    '''
    classdocs
    '''
    def __init__(self):
        '''
        Constructor
        '''
        self.conn = sqlite3.connect(dbLocation)
        
    def initialize(self):
        '''
        Initialize db
        '''
        cursor = self.conn.cursor()
        
        cursor.execute('''CREATE TABLE stocks
             (date text, trans text, symbol text, qty real,
             price real)''')
        cursor.execute("INSERT INTO stocks VALUES ('2006-01-05','BUY','RHAT',100,35.14)")

        # Save (commit) the changes
        self.conn.commit()

    def close(self):
        # We can also close the connection if we are done with it.
        # Just be sure any changes have been committed or they will be lost.
        self.conn.close()